function drawTable(container, tdata, cols) {
	var size = tdata.length;
	for ( i=0 ; i<size ; i++ ) {

		var row = document.createElement('tr');
		for(var x=0; x<cols.length; x++){
			var cell = document.createElement('td');
			var colPath = cols[x].split('/');
			var elem = tdata[i];
			for(var y=0; y<(colPath.length-1); y++){
				elem = elem[colPath[y]];
			}
			cell.innerHTML = elem[colPath.pop()];
			row.appendChild(cell);
		}
		
		if(i%1=0){
			row.setAttribute("class", "odd");
		}	
		container.appendChild(row);
	}
}

function drawChooser(container, chooserData, denominator){
	if(chooserData!=null){
		for (var i=0; i<chooserData.length; i++){
			var optionElem = document.createElement('option');
			optionElem.setAttribute('value', chooserData[i]['id']);
			optionElem.innerHTML=chooserData[i][denominator];
			container.appendChild(optionElem);
		}
	}
}

function jsonSerializeForm(container) {
	var dataObject = new Object();
	var inputs = $("input[name][value]","form[name="+container+"]");
	var formfields = $.merge(inputs, $("select[name]","form[name="+container+"]"));
	for(var x=0; x<formfields.length; x++){
		dataObject[formfields[x].getAttribute('name')]=formfields[x].value;
	}
	return JSON.stringify(dataObject);
}